#include "Blocks/AttachedSignBlock.h"
#include "Blocks/PostedSignBlock.h"

namespace PocketSurvival
{

    AttachedSignBlock::AttachedSignBlock(int32_t postedSign) : postedSignBlockIndex(postedSign)
    {
        addInheritance(this);
        addInheritance((IPaintableBlock *)this);
    }

    void AttachedSignBlock::getDropValues(int32_t oldValue, int32_t newValue, int32_t toolLevel, std::vector<BlockDropValue> &dropValues)
    {
        int32_t color = GetColor(Terrain::ExtractData(oldValue));
        int32_t data = PostedSignBlock::SetColor(0, color);
        dropValues.push_back(BlockDropValue{Terrain::MakeBlockValue(postedSignBlockIndex, 0, data), 1});
    }

    const std::vector<BoundingBox> &AttachedSignBlock::getCustomCollisionBoxes(int32_t value)
    {
        int32_t face = GetFace(Terrain::ExtractData(value));
        return BlockConstans::attachedSignCollisionBoxes[face];
    }

    int32_t AttachedSignBlock::getPaintColor(int32_t value)
    {
        return GetColor(Terrain::ExtractData(value));
    }

    int32_t AttachedSignBlock::paint(int32_t value, int32_t color)
    {
        int32_t data = Terrain::ExtractData(value);
        return Terrain::ReplaceData(value, SetColor(data, color));
    }

} // namespace PocketSurvival
